# 面向对象
class Student:
    def __init__(self, n, a, s):
        '''初始化方法'''
        print('我的__init__被调用！！！')
        self.name = n
        self.age = a
        self.__score = s  # 将 score 变为私有属性
    def set_score(self, new_score):
        if new_score < 0 or new_score > 100:
            print('您的输入有误，设置成绩失败')
            return
        # student['score'] = new_score
        self.__score = new_score
        print('log:', self.name, '的成绩被更改为', new_score)

    def set_new_year_age(self):
        self.age += 1

    def __hello(self):
        '私有方法，只能在本类的方法里调用'
        print("hello")
    def print_info(self):
        print('姓名：', self.name,
              '年龄为：', self.age, '的成绩是', self.__score)

class Doctor(Student):
    def set_score(self, new_score):
        if new_score < 0 or new_score > 150:
            print('您的输入有误，设置成绩失败')
            return
        # student['score'] = new_score
        self.__score = new_score  # 私有属性
        print('log:', self.name, '的成绩被更改为', new_score)

student1 = Student('魏眀择', 35, 0)   # 创建了一个对象
# student1.name = '魏眀择'
# student1.age = 35
# student1.score = 0
# student1 = {
#     'name': '魏眀择',
#     'age': 35,
#     'score': 0
# }
student2 = Student('小张', 18, 59)   # 创建了一个对象
# student2.name = '小张'
# student2.age = 18
# student2.score = 59
# student2 = {
#     'name': '小张',
#     'age': 18,
#     'score': 59
# }

# set_score(student1, 60)
# Python中 示例方法有两种调用方式
# 1) 类名.方法名(对象, 参数1)
# 2) 对象.方法名(参数1)
student1.set_score(60)  # Student.set_score(student1, 60)
Student.set_score(student2, 89)

Student.set_score(student1, 999)
student1.__score = 99999  # 错误操作

Student.print_info(student1)
Student.print_info(student2)




